

#include "CxTransaction.h"
#include "CxGlobalVariable.h"


using namespace MSG_SIGN;


void		CxTransaction::sendStdCmd(const _Data &src)
{
	CxGlobalVariable  gl;
	_Data *dest=new _Data;
	dest->push_back(0x05);
	dest->push_back(src[0]);
	dest->push_back(src[1]);
	dest->push_back(src[2]);
	dest->push_back('O');
	dest->push_back('K');
	gl.getPort()->async_write(dest->data(),dest->size(),[dest](bool){delete dest;});
}


CxTransaction  * CxTransaction::create(CommandID id, size_t cardid ,const vector<byte>& data)
{
	switch(id)
	{
	case CID_settime:
		return new CxSetTimeCommand(data,cardid);
		break;
	case CID_readtime:
		return new CxRdTimeCommand(data,cardid);
		break;
	case CID_markimg:
		return new CxMarkImgCommand(data,cardid);
		break;
	case CID_sendimg:
		return new CxPicCommand(data,cardid);
		break;
	case CID_sendprolist:
		return new CxProListCommand(data,cardid);
		break;
	case CID_showtext:
		return new CxShowTextCommand(data,cardid);
		break;
	case CID_line:
		return new CxLineCommand(data,cardid);
		break;
	case CID_loseiscomplete:
		return new CxLoseIsCommand(data,cardid);
		break;
	case CID_readlose:
		return new CxReadLoseCommand(data,cardid);
		break;
	case CID_readpower:
		return new CxReadPowerCommand(data,cardid);
		break;
	case CID_readworkstate:
		return new	CxReadStateCommand(data,cardid);
		break;

	default:
		return new CxCommonCommand(id,data,cardid);
		break;
	}
}
